import {
  Component,
  inject,
  input
} from '@angular/core';
import {Card} from '../../shared/card/card';

import { type TaskModel } from './task.model';

import { TasksService } from '../tasks.service';
import {DatePipe} from '@angular/common';

@Component({
  selector: 'app-task',
  imports: [
    Card,
    DatePipe
  ],
  templateUrl: './task.html',
  styleUrl: './task.css'
})
export class Task {
  task = input.required<TaskModel>();
  private tasksService = inject(TasksService);

  onComplete() {
    this.tasksService.removeTask(this.task().id);
  }
}
